import org.junit.Test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class Mytest {


//    @Test
//    public void test1() {
//        System.out.println("hello11111");
//    }

    @Test
    public void testJDBC() throws Exception{
        Class.forName("com.mysql.cj.jdbc.Driver");

        //2 获取连接
        String username = "root";
        String password = "123456";
        String url = "jdbc:mysql://localhost:3306/zuoye1?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai";
        Connection conn = DriverManager.getConnection(url, username, password);//通过DriverManager管理驱动获取连接

        //3 准备发送SQL的工具
        String sql = "select * from t_user";
        PreparedStatement pstm = conn.prepareStatement(sql);

        //4 发送执行SQL
        ResultSet rs = pstm.executeQuery();

        while(rs.next()){

        }
        rs.close();
        pstm.close();
        conn.close();
    }
}
